{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "%load_ext autoreload\n",
    "%autoreload 2\n",
    "import numpy as np\n",
    "import math, random, sympy\n",
    "import itertools"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [],
   "source": [
    "P_i = np.eye(2)\n",
    "P_x = np.array([[0.,1.],[1.,0.]])\n",
    "P_y = np.array([[0.,-1.j],[1.j,0.]])\n",
    "P_z = np.array([[1.,0.],[0.,-1.]])\n",
    "\n",
    "def read_txt(fname):\n",
    "    lines = []\n",
    "    nq = 0\n",
    "    nt = 0\n",
    "    \n",
    "    with open(fname, 'r') as f:\n",
    "        lines = f.readlines()\n",
    "    if (len(lines) > 0):\n",
    "        nq, nt = [int(s) for s in lines[0].split(',')]\n",
    "    assert(len(lines) == nt+1)\n",
    "    G_x = np.zeros((nq, nt), dtype=int)\n",
    "    G_z = np.zeros((nq, nt), dtype=int)\n",
    "    for i in range(nt):\n",
    "        s = lines[i+1]\n",
    "        #print(s)\n",
    "        assert(len(s) == nq+1)\n",
    "        for (j,c) in enumerate(s):\n",
    "            if (c == 'X' or c == 'Y'):\n",
    "                G_x[j][i] = True\n",
    "            if (c == 'Z' or c == 'Y'):\n",
    "                G_z[j][i] = True\n",
    "    return G_x,G_z\n",
    "\n",
    "def write_txt(fname, pauli_strings):\n",
    "    nt = len(pauli_strings)\n",
    "    if (nt > 0):\n",
    "        nq = len(pauli_strings[0])\n",
    "    else:\n",
    "        nq = 0\n",
    "    with open(fname, 'w+') as f:\n",
    "        f.write('%d,%d\\n' % (nq, nt))\n",
    "        for p in pauli_strings:\n",
    "            f.write('%s\\n' % p)\n",
    "    return nq, nt\n",
    "    \n",
    "def stab_to_matrix(row):\n",
    "    # (x,z)\n",
    "    nq = int(row.shape[1]/2)\n",
    "    ps = []\n",
    "    for i in range(nq):\n",
    "        if (row[0,i] == 1):\n",
    "            if (row[0,nq+i] == 1):\n",
    "                ps.append(P_y)\n",
    "            else:\n",
    "                ps.append(P_x)\n",
    "        else:\n",
    "            if (row[0,nq+i] == 1):\n",
    "                ps.append(P_z)\n",
    "            else:\n",
    "                ps.append(P_i)\n",
    "    mat = ps[0]\n",
    "    for j in range(len(ps)-1):\n",
    "        mat = np.kron(mat, ps[j+1])\n",
    "    return mat\n",
    "    \n",
    "def stab_dot(a, b):\n",
    "    # a,b as rows (x,z)\n",
    "    nq = int(a.shape[1]/2)\n",
    "    assert(a.shape == (1, 2*nq) and b.shape == (1, 2*nq))\n",
    "    res = a[:,:nq] @ b[:,nq:].T + a[:,nq:] @ b[:,:nq].T\n",
    "    return res[0,0] % 2\n",
    "\n",
    "def check_comm(i, tau, sub, nq):\n",
    "    t = tau[i]\n",
    "    res = True\n",
    "    for j in range(len(sub)):\n",
    "        sigx = np.zeros((1,nq*2))\n",
    "        sigx[0,sub[j]] = 1 # (x,z)\n",
    "        if (i==j):\n",
    "            if (stab_dot(tau[i], sigx) == 0):\n",
    "                return False\n",
    "        else:\n",
    "            if (stab_dot(tau[i], sigx) == 1):\n",
    "                return False\n",
    "    return True\n",
    "\n",
    "def close_up_to_phase(U1, U2):\n",
    "    return np.allclose(np.absolute(np.trace(U1 @ np.matrix(U2).getH())), 2) \n",
    "    \n",
    "def tensor_decomp(U):\n",
    "    if (U == None):\n",
    "        print(\"Error: exceed recursive levels.\")\n",
    "        return None\n",
    "    r, c = U.shape\n",
    "    assert(r == c)\n",
    "    if (r == 2):\n",
    "        #print(U)\n",
    "        if (close_up_to_phase(U, P_i)):\n",
    "            return ('I', None)\n",
    "        elif (close_up_to_phase(U, P_x)):\n",
    "            return ('X', None)\n",
    "        elif (close_up_to_phase(U, P_y)):\n",
    "            return ('Y', None)\n",
    "        elif (close_up_to_phase(U, P_z)):\n",
    "            return ('Z', None)\n",
    "        else:\n",
    "            print(\"Error: Do not recognize base case.\")\n",
    "            return None\n",
    "    elif (r > 2):\n",
    "        side = int(r / 2)\n",
    "        U00 = U[:side,:side]\n",
    "        U01 = U[:side,side:]\n",
    "        U10 = U[side:,:side]\n",
    "        U11 = U[side:,side:]\n",
    "        if (np.allclose(U01, np.zeros((side,side))) and np.allclose(U10, np.zeros((side,side)))):\n",
    "            if (np.allclose(U00, U11)):\n",
    "                return 'I', U00\n",
    "            elif (np.allclose(U00, -U11)):\n",
    "                return 'Z', U00\n",
    "            else:\n",
    "                print(\"Error: Do not recognize1.\")\n",
    "                return None\n",
    "            \n",
    "        elif (np.allclose(U00, np.zeros((side,side))) and np.allclose(U11, np.zeros((side,side)))):\n",
    "            if (np.allclose(U01, U10)):\n",
    "                return 'X', U10\n",
    "            elif (np.allclose(U01, -U10)):\n",
    "                return 'Y', -1.j*U10\n",
    "            else:\n",
    "                print(\"Error: Do not recognize2.\")\n",
    "                return None\n",
    "            \n",
    "        else:\n",
    "            print(\"Error: Do not recognize3.\")\n",
    "            return None\n",
    "        \n",
    "def get_term(i, G_x, G_z):\n",
    "    return np.array([np.concatenate((G_x[:,i], G_z[:,i]), axis=0).T])\n",
    "    \n",
    "def tapering(outfname, G_x, G_z):\n",
    "    E = np.concatenate((G_z.T, G_x.T), axis=1)\n",
    "    nt, nq = E.shape\n",
    "    nq = int(nq/2)\n",
    "    #print(E)\n",
    "    ns = sympy.Matrix(E).nullspace()\n",
    "    k = len(ns)\n",
    "    if (k == 0):\n",
    "        print(\"Nothing to taper.\")\n",
    "    tau = []\n",
    "    for i in range(k):\n",
    "        taui = np.array(ns[i]).astype(int)\n",
    "        taui = np.mod(taui, np.full(taui.shape, 2))\n",
    "        tau.append(taui.T) # as rows\n",
    "    # Choose k qubits\n",
    "    subs = list(itertools.combinations(range(nq), k))\n",
    "    found = None\n",
    "    for sub in subs:\n",
    "        res = True\n",
    "        for i in range(k):\n",
    "            res = res and check_comm(i, tau, sub, nq)\n",
    "        if (res):\n",
    "            found = sub\n",
    "    U = np.eye(2**nq)\n",
    "    if (found != None or len(found) > 0):\n",
    "        print(\"Hey! Found one possibility of tapering qubits: \")\n",
    "        print(found)\n",
    "        for i in range(k):\n",
    "            sigx = np.zeros((1,nq*2), dtype=int)\n",
    "            sigx[0,found[i]] = 1 # (x,z)\n",
    "            Ui = 1./math.sqrt(2) * (stab_to_matrix(sigx) + stab_to_matrix(tau[i]))\n",
    "            U = U @ Ui\n",
    "    new_terms = []\n",
    "    #print(U)\n",
    "    for r in range(nt):\n",
    "        new_term = ''\n",
    "        V = np.matrix(U).getH() @ stab_to_matrix(get_term(r, G_x, G_z)) @ U\n",
    "        for j in range(nq):\n",
    "            p, V = tensor_decomp(V) # U = p tensor V\n",
    "            new_term += p\n",
    "        new_terms.append(new_term)\n",
    "    print(new_terms)\n",
    "    write_txt(outfname, new_terms)\n",
    "    \n",
    "    return U\n",
    "            \n",
    "def transform(infname, outfname):\n",
    "    # Take a file with pauli strings,\n",
    "    # Produce another file with new pauli strings\n",
    "    # Return the transformation U applied to all strings\n",
    "    G_x, G_z = read_txt(infname)\n",
    "    U = tapering(outfname, G_x, G_z)\n",
    "    return U"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "4 14\n",
      "Hey! Found one possibility of tapering qubits: \n",
      "(1, 2, 3)\n",
      "['ZIII', 'ZXII', 'ZIXI', 'ZIIX', 'IXII', 'IIXI', 'IIIX', 'IXXI', 'IXIX', 'IIXX', 'XIXX', 'XIIX', 'XXXI', 'XXII']\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "/software/Anaconda3-5.0.1-el7-x86_64/lib/python3.6/site-packages/ipykernel/__main__.py:86: FutureWarning: comparison to `None` will result in an elementwise object comparison in the future.\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "array([[ 0.35355339,  0.35355339,  0.35355339,  0.35355339,  0.35355339,\n",
       "         0.35355339,  0.35355339,  0.35355339,  0.        ,  0.        ,\n",
       "         0.        ,  0.        ,  0.        ,  0.        ,  0.        ,\n",
       "         0.        ],\n",
       "       [ 0.35355339, -0.35355339,  0.35355339, -0.35355339,  0.35355339,\n",
       "        -0.35355339,  0.35355339, -0.35355339,  0.        ,  0.        ,\n",
       "         0.        ,  0.        ,  0.        ,  0.        ,  0.        ,\n",
       "         0.        ],\n",
       "       [ 0.35355339,  0.35355339, -0.35355339, -0.35355339,  0.35355339,\n",
       "         0.35355339, -0.35355339, -0.35355339,  0.        ,  0.        ,\n",
       "         0.        ,  0.        ,  0.        ,  0.        ,  0.        ,\n",
       "         0.        ],\n",
       "       [ 0.35355339, -0.35355339, -0.35355339,  0.35355339,  0.35355339,\n",
       "        -0.35355339, -0.35355339,  0.35355339,  0.        ,  0.        ,\n",
       "         0.        ,  0.        ,  0.        ,  0.        ,  0.        ,\n",
       "         0.        ],\n",
       "       [ 0.35355339,  0.35355339,  0.35355339,  0.35355339, -0.35355339,\n",
       "        -0.35355339, -0.35355339, -0.35355339,  0.        ,  0.        ,\n",
       "         0.        ,  0.        ,  0.        ,  0.        ,  0.        ,\n",
       "         0.        ],\n",
       "       [ 0.35355339, -0.35355339,  0.35355339, -0.35355339, -0.35355339,\n",
       "         0.35355339, -0.35355339,  0.35355339,  0.        ,  0.        ,\n",
       "         0.        ,  0.        ,  0.        ,  0.        ,  0.        ,\n",
       "         0.        ],\n",
       "       [ 0.35355339,  0.35355339, -0.35355339, -0.35355339, -0.35355339,\n",
       "        -0.35355339,  0.35355339,  0.35355339,  0.        ,  0.        ,\n",
       "         0.        ,  0.        ,  0.        ,  0.        ,  0.        ,\n",
       "         0.        ],\n",
       "       [ 0.35355339, -0.35355339, -0.35355339,  0.35355339, -0.35355339,\n",
       "         0.35355339,  0.35355339, -0.35355339,  0.        ,  0.        ,\n",
       "         0.        ,  0.        ,  0.        ,  0.        ,  0.        ,\n",
       "         0.        ],\n",
       "       [ 0.        ,  0.        ,  0.        ,  0.        ,  0.        ,\n",
       "         0.        ,  0.        ,  0.        , -0.35355339,  0.35355339,\n",
       "         0.35355339, -0.35355339,  0.35355339, -0.35355339, -0.35355339,\n",
       "         0.35355339],\n",
       "       [ 0.        ,  0.        ,  0.        ,  0.        ,  0.        ,\n",
       "         0.        ,  0.        ,  0.        ,  0.35355339,  0.35355339,\n",
       "        -0.35355339, -0.35355339, -0.35355339, -0.35355339,  0.35355339,\n",
       "         0.35355339],\n",
       "       [ 0.        ,  0.        ,  0.        ,  0.        ,  0.        ,\n",
       "         0.        ,  0.        ,  0.        ,  0.35355339, -0.35355339,\n",
       "         0.35355339, -0.35355339, -0.35355339,  0.35355339, -0.35355339,\n",
       "         0.35355339],\n",
       "       [ 0.        ,  0.        ,  0.        ,  0.        ,  0.        ,\n",
       "         0.        ,  0.        ,  0.        , -0.35355339, -0.35355339,\n",
       "        -0.35355339, -0.35355339,  0.35355339,  0.35355339,  0.35355339,\n",
       "         0.35355339],\n",
       "       [ 0.        ,  0.        ,  0.        ,  0.        ,  0.        ,\n",
       "         0.        ,  0.        ,  0.        ,  0.35355339, -0.35355339,\n",
       "        -0.35355339,  0.35355339,  0.35355339, -0.35355339, -0.35355339,\n",
       "         0.35355339],\n",
       "       [ 0.        ,  0.        ,  0.        ,  0.        ,  0.        ,\n",
       "         0.        ,  0.        ,  0.        , -0.35355339, -0.35355339,\n",
       "         0.35355339,  0.35355339, -0.35355339, -0.35355339,  0.35355339,\n",
       "         0.35355339],\n",
       "       [ 0.        ,  0.        ,  0.        ,  0.        ,  0.        ,\n",
       "         0.        ,  0.        ,  0.        , -0.35355339,  0.35355339,\n",
       "        -0.35355339,  0.35355339, -0.35355339,  0.35355339, -0.35355339,\n",
       "         0.35355339],\n",
       "       [ 0.        ,  0.        ,  0.        ,  0.        ,  0.        ,\n",
       "         0.        ,  0.        ,  0.        ,  0.35355339,  0.35355339,\n",
       "         0.35355339,  0.35355339,  0.35355339,  0.35355339,  0.35355339,\n",
       "         0.35355339]])"
      ]
     },
     "execution_count": 13,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "hydro = ['ZIII','IZII','IIZI','IIIZ','ZZII','ZIZI','ZIIZ','IZZI','IZIZ','IIZZ','YYXX','XYYX','YXXY','XXYY']\n",
    "nq, nt = write_txt('taper_test.txt', hydro)\n",
    "print(nq, nt)\n",
    "transform('taper_test.txt', 'tapered_res.txt')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Nothing to taper.\n",
      "Hey! Found one possibility of tapering qubits: \n",
      "()\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "/software/Anaconda3-5.0.1-el7-x86_64/lib/python3.6/site-packages/ipykernel/__main__.py:86: FutureWarning: comparison to `None` will result in an elementwise object comparison in the future.\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "['IIIIIIII', 'XXYYIIII', 'XXYZZZZY', 'XXIXZZXI', 'XXIIYYII', 'XXIIIIYY', 'XYYXIIII', 'XYYZZZZX', 'XYIYZZXI', 'XYIIYXII', 'XYIIIIYX', 'XZXXZXII', 'XZXYZYII', 'XZXIXZXI', 'XZXIYZYI', 'XZXIIXZX', 'XZXIIYZY', 'XZYIYZXI', 'XZZXYZZY', 'XZZXIXXI', 'XZZYYZZX', 'XZZYIYXI', 'XZZZXIII', 'XZZZXZII', 'XZZZXIZI', 'XZZZXIIZ', 'XZZZZXYY', 'XZZZZYYX', 'XZZIXIII', 'XZIZXIII', 'XIZZXIII', 'YXXYIIII', 'YXXZZZZY', 'YXIXZZYI', 'YXIIXYII', 'YXIIIIXY', 'YYXXIIII', 'YYXZZZZX', 'YYIYZZYI', 'YYIIXXII', 'YYIIIIXX', 'YZXIXZYI', 'YZYXZXII', 'YZYYZYII', 'YZYIXZXI', 'YZYIYZYI', 'YZYIIXZX', 'YZYIIYZY', 'YZZXXZZY', 'YZZXIXYI', 'YZZYXZZX', 'YZZYIYYI', 'YZZZYIII', 'YZZZYZII', 'YZZZYIZI', 'YZZZYIIZ', 'YZZZZXXY', 'YZZZZYXX', 'YZZIYIII', 'YZIZYIII', 'YIZZYIII', 'ZIIIIIII', 'ZXZZZXII', 'ZYZZZYII', 'ZZIIIIII', 'ZIXZZZXI', 'ZIYZZZYI', 'ZIZIIIII', 'ZIIXZZZX', 'ZIIYZZZY', 'ZIIZIIII', 'ZIIIZIII', 'ZIIIIZII', 'ZIIIIIZI', 'ZIIIIIIZ', 'IXXYYIII', 'IXXIXZZX', 'IXXIIYYI', 'IXYYXIII', 'IXYIYZZX', 'IXYIIYXI', 'IXZXXZXI', 'IXZXYZYI', 'IXZXIXZX', 'IXZXIYZY', 'IXZYIYZX', 'IXZZXIXX', 'IXZZYIYX', 'IXZZZXII', 'IXZZZXZI', 'IXZZZXIZ', 'IXZZIXII', 'IXZIZXII', 'IXIZZXII', 'IYXXYIII', 'IYXIXZZY', 'IYXIIXYI', 'IYYXXIII', 'IYYIYZZY', 'IYYIIXXI', 'IYZXIXZY', 'IYZYXZXI', 'IYZYYZYI', 'IYZYIXZX', 'IYZYIYZY', 'IYZZXIXY', 'IYZZYIYY', 'IYZZZYII', 'IYZZZYZI', 'IYZZZYIZ', 'IYZZIYII', 'IYZIZYII', 'IYIZZYII', 'IZIIIIII', 'IZXZZZXI', 'IZYZZZYI', 'IZZIIIII', 'IZIXZZZX', 'IZIYZZZY', 'IZIZIIII', 'IZIIZIII', 'IZIIIZII', 'IZIIIIZI', 'IZIIIIIZ', 'IIXXYYII', 'IIXXIIYY', 'IIXYYXII', 'IIXYIIYX', 'IIXZXXZX', 'IIXZXYZY', 'IIXZZZXI', 'IIXZZZXZ', 'IIXZZIXI', 'IIXZIZXI', 'IIXIZZXI', 'IIYXXYII', 'IIYXIIXY', 'IIYYXXII', 'IIYYIIXX', 'IIYZYXZX', 'IIYZYYZY', 'IIYZZZYI', 'IIYZZZYZ', 'IIYZZIYI', 'IIYZIZYI', 'IIYIZZYI', 'IIZIIIII', 'IIZXZZZX', 'IIZYZZZY', 'IIZZIIII', 'IIZIZIII', 'IIZIIZII', 'IIZIIIZI', 'IIZIIIIZ', 'IIIXXYYI', 'IIIXYYXI', 'IIIXZZZX', 'IIIXZZIX', 'IIIXZIZX', 'IIIXIZZX', 'IIIYXXYI', 'IIIYYXXI', 'IIIYZZZY', 'IIIYZZIY', 'IIIYZIZY', 'IIIYIZZY', 'IIIZIIII', 'IIIZZIII', 'IIIZIZII', 'IIIZIIZI', 'IIIZIIIZ', 'IIIIXXYY', 'IIIIXYYX', 'IIIIYXXY', 'IIIIYYXX', 'IIIIZIII', 'IIIIZZII', 'IIIIZIZI', 'IIIIZIIZ', 'IIIIIZII', 'IIIIIZZI', 'IIIIIZIZ', 'IIIIIIZI', 'IIIIIIZZ', 'IIIIIIIZ']\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "array([[ 1.,  0.,  0., ...,  0.,  0.,  0.],\n",
       "       [ 0.,  1.,  0., ...,  0.,  0.,  0.],\n",
       "       [ 0.,  0.,  1., ...,  0.,  0.,  0.],\n",
       "       ..., \n",
       "       [ 0.,  0.,  0., ...,  1.,  0.,  0.],\n",
       "       [ 0.,  0.,  0., ...,  0.,  1.,  0.],\n",
       "       [ 0.,  0.,  0., ...,  0.,  0.,  1.]])"
      ]
     },
     "execution_count": 14,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "transform('sample.txt', 'sample_res.txt')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Hey! Found one possibility of tapering qubits: \n",
      "(5, 7)\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "/software/Anaconda3-5.0.1-el7-x86_64/lib/python3.6/site-packages/ipykernel/__main__.py:86: FutureWarning: comparison to `None` will result in an elementwise object comparison in the future.\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "['IIIIIIII', 'XYXYIIII', 'XXZYYXII', 'XYIXYIZX', 'XYIXZIYX', 'XYIYXIII', 'XXIYYXII', 'XXIYYXZI', 'XYIYIIXI', 'XYIZYIZI', 'XYIZZIYI', 'XXXIYIYI', 'XYYXZXII', 'XYYZZXIX', 'XXYIXIYI', 'XXYIYIXI', 'XYYIIXZI', 'XYZXYXII', 'XYZZYXIX', 'XYZIIXYI', 'XYIYXXII', 'XZXIIIII', 'XZXXIIIX', 'XZXZIIII', 'XZIIXIII', 'XZIIIIXI', 'XZYYIXZI', 'XZZYIXYI', 'XZIXIXXI', 'XZIZIXXX', 'XZIIXXII', 'YYYYIIII', 'YXZYXXII', 'YYIXXIZX', 'YYIXZIXX', 'YXIYXXII', 'YXIYXXZI', 'YYIYYIII', 'YYIYIIYI', 'YYIZXIZI', 'YYIZZIXI', 'YYXXZXII', 'YYXZZXIX', 'YXXIXIYI', 'YXXIYIXI', 'YYXIIXZI', 'YXYIXIXI', 'YYZXXXII', 'YYZZXXIX', 'YYZIIXXI', 'YYIYYXII', 'YZYIIIII', 'YZYXIIIX', 'YZYZIIII', 'YZIIYIII', 'YZIIIIYI', 'YZXYIXZI', 'YZZYIXXI', 'YZIXIXYI', 'YZIZIXYX', 'YZIIYXII', 'ZIIIIIII', 'ZYZYIIII', 'ZYIXXIYX', 'ZYIXYIXX', 'ZXIXIXZX', 'ZYIYZIII', 'ZYIYIIII', 'ZYIYIIZI', 'ZYIZXIYI', 'ZYIZYIXI', 'ZXIZIXZI', 'ZXIIZXIX', 'ZYXXYXII', 'ZYXZYXIX', 'ZYXIIXYI', 'ZYYXXXII', 'ZYYZXXIX', 'ZYYIIXXI', 'ZXZXIIII', 'ZXZZIIIX', 'ZYIYZXII', 'ZZIIIIII', 'ZIXYIXYI', 'ZIYYIXXI', 'ZZZIIIII', 'ZZZXIIIX', 'ZZZZIIII', 'ZIIXIXZI', 'ZIIZIXZX', 'ZZIIZIII', 'ZIIIZXII', 'ZZIIIIZI', 'ZZXYIXYI', 'ZZYYIXXI', 'ZIZIIIII', 'ZIZXIIIX', 'ZIZZIIII', 'ZZIXIXZI', 'ZZIZIXZX', 'ZIIIZIII', 'ZZIIZXII', 'ZIIIIIZI', 'IYXIYIZI', 'IYXIZIYI', 'IYYIXIZI', 'IYYIZIXI', 'IXZXZXII', 'IXZZZXIX', 'IYZIXIYI', 'IYZIYIXI', 'IXZIIXZI', 'IYIYIIII', 'IYXYXXII', 'IYYYYXII', 'IYZYZXII', 'IXIXZIZX', 'IYIYXXXI', 'IYIYYXYI', 'IYIYZXII', 'IYIYZXZI', 'IYIYIXII', 'IXIZZIZI', 'IZIIIIII', 'IZXXXIIX', 'IZXXIIXX', 'IZXYYIZI', 'IIXYZXYI', 'IZXYZIYI', 'IIXYIXYI', 'IZXZXIII', 'IZXZIIXI', 'IZYXYIIX', 'IZYXIIYX', 'IZYYXIZI', 'IIYYZXXI', 'IZYYZIXI', 'IIYYIXXI', 'IZYZYIII', 'IZYZIIYI', 'IIZXZXIX', 'IZZXZIIX', 'IZZXIIZX', 'IZZXIIIX', 'IZZYXIYI', 'IZZYYIXI', 'IZZZIIII', 'IZZZZIII', 'IIZZZXII', 'IZZZIIZI', 'IIZIIXZX', 'IZIXIIIX', 'IZIZIIII', 'IZXXIXXI', 'IZXZIXXX', 'IZXIXXII', 'IZYXIXYI', 'IZYZIXYX', 'IZYIYXII', 'IIZIIIII', 'IZZXIXZI', 'IZZZIXZX', 'IIZIZIII', 'IZZIZXII', 'IIZIIIZI', 'IZIXXXXI', 'IZIXYXYI', 'IZIXZXZI', 'IIIXZIZI', 'IZIXIXII', 'IZIXIXZI', 'IZIZXXXX', 'IZIZYXYX', 'IZIZZXZX', 'IIIZZIZX', 'IZIZIXZX', 'IZIZIXIX', 'IZIIXXXI', 'IZIIYXYI', 'IIIIZIII', 'IZIIZXII', 'IZIIZXZI', 'IIIIZIZI', 'IZIIIXII', 'IIIIIIZI']\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "array([[ 0.5,  0.5,  0. , ...,  0. ,  0. ,  0. ],\n",
       "       [ 0.5, -0.5,  0. , ...,  0. ,  0. ,  0. ],\n",
       "       [ 0. ,  0. ,  0.5, ...,  0. ,  0. ,  0. ],\n",
       "       ..., \n",
       "       [ 0. ,  0. ,  0. , ..., -0.5,  0. ,  0. ],\n",
       "       [ 0. ,  0. ,  0. , ...,  0. ,  0.5,  0.5],\n",
       "       [ 0. ,  0. ,  0. , ...,  0. ,  0.5, -0.5]])"
      ]
     },
     "execution_count": 15,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "transform('H2_6-31g_BKT_0.7_AS4.txt', 'H2_6-31g_BKT_0.7_AS4_res.txt')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Hey! Found one possibility of tapering qubits: \n",
      "(5, 9)\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "/software/Anaconda3-5.0.1-el7-x86_64/lib/python3.6/site-packages/ipykernel/__main__.py:86: FutureWarning: comparison to `None` will result in an elementwise object comparison in the future.\n"
     ]
    }
   ],
   "source": [
    "transform('H2O_6-31g_JW_104_AS6.txt', 'H2O_6-31g_JW_104_AS6_res.txt')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python [default]",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
